package com.teacherprofile.common.enums;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonValue;

public enum LearningForms {
    FULL_TIME(0, "全日制"),
    PART_TIME(1, "非全日制"),
    OTHER(100, "其他");

    @JsonValue
    @EnumValue
    private final int code;
    private final String description;

    LearningForms(int code, String description) {
        this.code = code;
        this.description = description;
    }

    public int getCode() {
        return code;
    }

    public String getDescription() {
        return description;
    }

    public static LearningForms fromCode(int code) {
        for (LearningForms form : values()) {
            if (form.code == code) {
                return form;
            }
        }
        throw new IllegalArgumentException("Invalid LearningForms code: " + code);
    }
}